﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master" AutoEventWireup="true"
  CodeBehind="GroupDetail.aspx.cs" Inherits="NguyenHoa.Web.Admin.GroupDetail" Title="" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dxtc" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Src="../Controls/UserRight.ascx" TagName="UserRight" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div style="padding-left: 3px;">
    <dxtc:ASPxTabControl ID="ASPxTabControl1" runat="server" ActiveTabIndex="0" 
      Width="100%">
      <ClientSideEvents ActiveTabChanging="function(s, e) {onTabChange(s, e);}" />
      <TabStyle Width="55px">
      </TabStyle>
      <Tabs>
        <dxtc:Tab Name="GroupMembers" Text="<%$Resources:Strings, GroupMember %>">
        </dxtc:Tab>
        <dxtc:Tab Name="GroupPermission" Text="<%$Resources:Strings, GroupPermission %>">
        </dxtc:Tab>
      </Tabs>
    </dxtc:ASPxTabControl>
    <div id="frmGroupMember" style="padding-top: 10px;">
      <div style="padding-top: 10px;">
        <dxwgv:ASPxGridView ID="gvGroupMember" runat="server" AutoGenerateColumns="False"
          Width="550px" KeyFieldName="Username" OnCustomCallback="gvGroupMember_CustomCallback"
          OnCustomJSProperties="gvGroupMember_CustomJSProperties" ClientInstanceName="gvGroupMember">
          <SettingsBehavior AllowFocusedRow="True" AllowDragDrop="False" AllowGroup="False"
            AllowSort="False" />
          <SettingsPager>
            <AllButton>
              <Image Width="28px"></Image>
            </AllButton>
            <FirstPageButton>
              <Image Width="23px"></Image>
            </FirstPageButton>
            <LastPageButton>
              <Image Width="23px"></Image>
            </LastPageButton>
            <NextPageButton>
              <Image Width="19px"></Image>
            </NextPageButton>
            <PrevPageButton>
              <Image Width="19px"></Image>
            </PrevPageButton>
            <Summary AllPagesText="<%$Resources:Strings, PagerText %>" Text="<%$Resources:Strings, PagerText %>" />
          </SettingsPager>
          <Images>
            <CollapsedButton Width="13px">
            </CollapsedButton>
            <ExpandedButton Width="13px">
            </ExpandedButton>
            <DetailCollapsedButton Width="13px">
            </DetailCollapsedButton>
            <DetailExpandedButton Width="13px">
            </DetailExpandedButton>
            <HeaderFilter Width="19px">
            </HeaderFilter>
            <HeaderActiveFilter Width="19px">
            </HeaderActiveFilter>
            <HeaderSortDown Width="6px">
            </HeaderSortDown>
            <HeaderSortUp Width="6px">
            </HeaderSortUp>
            <FilterRowButton Width="13px"></FilterRowButton>
            <CustomizationWindowClose Width="18px"></CustomizationWindowClose>
            <PopupEditFormWindowClose Width="18px"></PopupEditFormWindowClose>
            <WindowResizer Width="12px">
            </WindowResizer>
            <FilterBuilderClose Width="18px"></FilterBuilderClose>
          </Images>
          <ClientSideEvents EndCallback="function(s, e) {ongvGroupMember_EndCallback(s, e);}" />
          <Columns>
            <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="20px">
              <HeaderStyle HorizontalAlign="Center" />
              <HeaderTemplate>
                <input type="checkbox" id="chkboxGroup" onclick="gvGroupMember.SelectAllRowsOnPage(this.checked);"
                  title="" style="" runat="server" value="false" />
              </HeaderTemplate>
            </dxwgv:GridViewCommandColumn>
            <dxwgv:GridViewDataTextColumn FieldName="Username" VisibleIndex="1" Caption="<%$Resources:Strings, Username %>">
              <HeaderStyle HorizontalAlign="Center" />
            </dxwgv:GridViewDataTextColumn>
            <dxwgv:GridViewDataTextColumn FieldName="Fullname" VisibleIndex="2" Caption="<%$Resources:Strings, FullName %>">
              <HeaderStyle HorizontalAlign="Center" />
            </dxwgv:GridViewDataTextColumn>
          </Columns>
          <ImagesEditors>
            <CalendarPrevYear Width="23px">
            </CalendarPrevYear>
            <CalendarPrevMonth Width="19px">
            </CalendarPrevMonth>
            <CalendarNextMonth Width="19px">
            </CalendarNextMonth>
            <CalendarNextYear Width="23px">
            </CalendarNextYear>
          </ImagesEditors>
        </dxwgv:ASPxGridView>
      </div>
      <div style="float: left; padding-top: 10px;">
        <dxe:ASPxButton ID="btnAdd" runat="server" Text="<%$ Resources:Strings, Add %>" 
          AutoPostBack="False">
          <ClientSideEvents Click="function(s, e) {onAdd(); }" />
        </dxe:ASPxButton>
      </div>
      <div style="float: left; padding-top: 10px; padding-left: 3px;">
        <dxe:ASPxButton ID="btnDelete" runat="server" Text="<%$ Resources:Strings, Delete %>"
          AutoPostBack="False">
          <ClientSideEvents Click="function(s, e) {onDelete(); }" />
        </dxe:ASPxButton>
      </div>
      <div style="float: left; padding-top: 10px; padding-left: 3px;">
        <dxe:ASPxButton ID="ASPxButton1" runat="server" Text="<%$ Resources:Strings, BackTo %>"
          AutoPostBack="False">
          <ClientSideEvents Click="function(s, e) {onBack(); }" />
        </dxe:ASPxButton>
      </div>
    </div>
    <div style="clear: both;">
      <dxpc:ASPxPopupControl ID="pcAdduser" ClientInstanceName="pcAddUser" runat="server"
        Width="400px" HeaderText="<%$ Resources:Strings, UserList %>" PopupHorizontalAlign="WindowCenter"
        PopupVerticalAlign="WindowCenter" Modal="True">
        <SizeGripImage Width="12px" />
        <ContentCollection>
          <dxpc:PopupControlContentControl>
            <div>
              <dxwgv:ASPxGridView ID="gvUser" ClientInstanceName="gvUser" runat="server" AutoGenerateColumns="False"
                KeyFieldName="Username" OnCustomCallback="gvUser_CustomCallback" Width="100%">
                <ClientSideEvents EndCallback="function(s, e) {ongvUser_EndCallback(s,e);}" />
                <Columns>
                  <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                    <HeaderStyle HorizontalAlign="Center" />
                    <HeaderTemplate>
                      <input id="Checkbox1" onclick="gvUser.SelectAllRowsOnPage(this.checked);" style="vertical-align: middle;"
                        title="" type="checkbox" runat="server" value="false" />
                    </HeaderTemplate>
                  </dxwgv:GridViewCommandColumn>
                  <dxwgv:GridViewDataTextColumn FieldName="Username" VisibleIndex="1" Caption="<%$Resources:Strings, Username %>">
                    <HeaderStyle HorizontalAlign="Center" />
                  </dxwgv:GridViewDataTextColumn>
                  <dxwgv:GridViewDataTextColumn FieldName="Fullname" VisibleIndex="2" Caption="<%$Resources:Strings, FullName %>">
                    <HeaderStyle HorizontalAlign="Center" />
                  </dxwgv:GridViewDataTextColumn>
                </Columns>
                <SettingsBehavior AllowFocusedRow="True" AllowDragDrop="False" AllowGroup="False"
                  AllowSort="False" />
                <SettingsPager>
                  <Summary AllPagesText="<%$Resources:Strings, PagerText %>" Text="<%$Resources:Strings, PagerText %>" />
                  <AllButton>
                    <Image Width="28px" />
                  </AllButton>
                  <FirstPageButton>
                    <Image Width="23px" />
                  </FirstPageButton>
                  <LastPageButton>
                    <Image Width="23px" />
                  </LastPageButton>
                  <NextPageButton>
                    <Image Width="19px" />
                  </NextPageButton>
                  <PrevPageButton>
                    <Image Width="19px" />
                  </PrevPageButton>
                </SettingsPager>
                <Images>
                  <CollapsedButton Width="13px" />
                  <ExpandedButton Width="13px" />
                  <DetailCollapsedButton Width="13px" />
                  <DetailExpandedButton Width="13px" />
                  <HeaderFilter
                    Width="19px" />
                  <HeaderActiveFilter
                    Width="19px" />
                  <HeaderSortDown Width="6px" />
                  <HeaderSortUp Width="6px" />
                  <FilterRowButton Width="13px" />
                  <CustomizationWindowClose Width="18px" />
                  <PopupEditFormWindowClose Width="18px" />
                  <WindowResizer Width="12px" />
                  <FilterBuilderClose Width="18px" />
                </Images>
                <ImagesEditors>
                  <CalendarPrevYear Width="23px" />
                  <CalendarPrevMonth Width="19px" />
                  <CalendarNextMonth Width="19px" />
                  <CalendarNextYear Width="23px" />
                </ImagesEditors>
              </dxwgv:ASPxGridView>
            </div>
            <div style="float: right; padding-top: 5px;">
              <dxe:ASPxButton ID="btnCancel" AutoPostBack="false" runat="server" Text="<%$Resources:Strings, Cancel %>"
                ClientInstanceName="btnCancel">
                <ClientSideEvents Click="function(s,e){onCancel();e.processOnServer = false;}" />
              </dxe:ASPxButton>
            </div>
            <div style="float: right; padding-right: 3px; padding-top: 5px;">
              <dxe:ASPxButton ID="btnSave" runat="server" Text="<%$Resources:Strings, Save %>">
                <ClientSideEvents Click="function(s,e){onSave();e.processOnServer = false;}" />
              </dxe:ASPxButton>
            </div>
          </dxpc:PopupControlContentControl>
        </ContentCollection>
        <CloseButtonImage Width="18px" />
      </dxpc:ASPxPopupControl>
    </div>
    <div id="frmGroupPermission" style="display: none; padding-top: 20px;">
      <uc1:UserRight ID="UserRight1" runat="server" />
    </div>
  </div>
  <div>
    <asp:XmlDataSource ID="xdsStatus" runat="server" XPath="Items/CommonStatus/Status">
    </asp:XmlDataSource>
    <asp:HiddenField ID="hfApproveCheckbox" runat="server" />
    <asp:HiddenField ID="hfApproveValue" runat="server" />
  </div>

  <script type="text/javascript" language="javascript">
    var hasChange = false;
    function onAdd() {
      gvUser.PerformCallback('Load|');
    }

    function onSave() {
      gvGroupMember.PerformCallback('Add|');
      pcAddUser.Hide();
    }

    function onBack() {
      window.location.href = 'Groups.aspx';
    }

    function onCancel() {
      pcAddUser.Hide();
    }

    function onDelete() {
      if (confirm('<%=GetGlobalResourceObject("Messages", "ERR0006") %>'))
        gvGroupMember.PerformCallback('Delete|');
    }

    function ongvUser_EndCallback(s, e) {
      gvUser.SelectAllRowsOnPage(false);
      pcAddUser.Show();
    }

    function ongvGroupMember_EndCallback(s, e) {
      var error = gvGroupMember.cpInnerError;
      if (error != '')
        alertMessage(error);
    }

    function showPermission(show) {
      if (show) {
        document.getElementById('frmGroupMember').style.display = 'none';
        if (hasChange) {
          //gvPermission.PerformCallback('Load|');
        }
        else {
          document.getElementById('frmGroupPermission').style.display = 'block';
        }
      }
      else {
        document.getElementById('frmGroupMember').style.display = 'block';
        document.getElementById('frmGroupPermission').style.display = 'none';
      }
    }

    function onTabChange(s, e) {
      var tabName = e.tab.name;
      if (tabName == "GroupPermission")
        showPermission(true);
      else
        showPermission(false);
    }
  </script>

</asp:Content>
